home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0793 / DIGSOUND.PAS < prev    next >
Pascal/Delphi Source File  |  1993-08-01  |  3KB  |  67 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 417 of 448                                                               
  3. From : Bernie Pallek                       1:247/128.0          24 Jul 93  11:11 
  4. To   : Matthew Mclin                                                             
  5. Subj : (1/2) Digital Sound                                                    
  6. ────────────────────────────────────────────────────────────────────────────────
  7. MM> Does anybody know the format of .MOD/.SAM/.WAV/.VOC file?
  8. MM> Info on any of those formats (how to read/write/play them
  9. MM> using a PC Speaker or LPT 1 with a mono DAC) would be
  10. MM> greatly appreciated. I would also like info on raw sound
  11. MM> data and how to edit/play it. Note that these .MOD and
  12. MM> .SAM files are in the Amiga Module format (just in case
  13.     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  14. MM> there are any others). Oh, there's
  15. MM> also the .SND files. Or even .MID/.MDI files if you can play
  16. MM> them thru a DAC on an LPT port or the PC Speaker. Note that I
  17. MM> don't have a Sound Blaster (or any other sound card). Thanks.
  18.  
  19. Well, Matt, digital sound is a complicated subject, but I can tell
  20. you a few things.
  21. First of all, .SAM files don't have a special format; they are just
  22. files with raw data.  The program that plays them has to determine
  23. the playback speed, etc.
  24. Now, about playing them back on a DAC.  Here is some information I
  25. collected, and added to.  The code is theoretic and untested!
  26. - - - 8<- - - - - - - - -S-N-I-P- -L-I-N-E- - - - - - - ->8 - - - -
  27. To output to a DAC, all you have to do is this:}
  28.  
  29. Port[$0378] := byteVal;  { byteVal could be read from a .VOC or .WAV file }
  30. { the port value is for LPT1; LPT2 may be $0388... not sure }
  31. {
  32. The data is best sent with a hi-res timer to even the flow.
  33. For example:}
  34.  
  35. { theoretic code to play TEST.SAM }
  36. CONST
  37.      LPT1         = $0378;
  38.      SoundName    = 'TEST.SAM';   { raw sample }
  39.      MaxSoundSize = 9999;  { max. file size of sound data }
  40.                            { this may be adjusted as necessary }
  41.  
  42. VAR
  43.    soundArray : ARRAY[0..MaxSoundSize] OF Byte;
  44.    soundLen   : LongInt;  { actual length of sound in bytes }
  45.    soundFile  : File;
  46.    result     : LongInt;
  47.    j          : LongInt;
  48.  
  49. BEGIN
  50.      Assign(soundFile, SoundName);
  51.      soundLen := GetFileSizeOf(SoundName);
  52.      Reset(soundFile, 1);   { record size of 1 }
  53.      BlockRead(soundFile, soundArray[0], soundLen, result);
  54.      Close(soundFile);
  55.      FOR j := 0 TO soundLen DO BEGIN
  56.          Port[LPT1] := soundArray[j];
  57.          { AccurateDelay;    <-- it's your job to write this :')  }
  58.      END;
  59. END.
  60. - - - 8<- - - - - - - - -S-N-I-P- -L-I-N-E- - - - - - - ->8 - - - -
  61. OK, I hope this helps you.  You may play .VOC files with the program
  62. (if it works :'), but note that they will have a static-sounding
  63. bit of garbage at the beginning, because of headers.  If you'd like,
  64. I can post you the .VOC header information, or I can put it on a
  65. board that you can call if you desperately need the info; I don't
  66. think UUencoding is allowed on this echo, or I'd send it to you
  67. that way.